export class CooldownManager {
  constructor() {
    this.map = new Map();
  }
  ready(key) {
    const until = this.map.get(key) || 0;
    return performance.now() >= until;
  }
  set(key, ms) {
    const now = performance.now();
    this.map.set(key, ms > 0 ? now + ms : now);
  }
  // 新增：获取剩余冷却毫秒数（若无或已就绪则为 0）
  get(key) {
    const until = this.map.get(key) || 0;
    const now = performance.now();
    return Math.max(0, until - now);
  }
  // 新增：删除某个键的冷却
  reset(key) { this.map.delete(key); }
  // 新增：清空所有冷却
  clear() { this.map.clear(); }
}